<?php

namespace Trawind\Skeleton\Generators;

use Prettus\Repository\Generators\Generator as PrettusGenerator;
use Prettus\Repository\Generators\Stub;

/**
 * Class Generator
 * @package Prettus\Repository\Generators
 * @author Anderson Andrade <contato@andersonandra.de>
 */
abstract class Generator extends PrettusGenerator
{


    public function getConfigGeneratorClassPath($class, $directoryPath = false)
    {
        switch ($class) {
            case ('remote_interfaces' === $class):
                $path = config('repository.generator.paths.remote_interfaces', 'Remotes\interfaces');
                break;
            case ('remote_repositories' === $class):
                $path = config('repository.generator.paths.remote_repositories', 'Remotes\repositories');
                break;
            default:
                $path = '';
                break;
        }

        
        if ($path != '') {
            if ($directoryPath) {
                $path = str_replace('\\', '/', $path);
            } else {
                $path = str_replace('/', '\\', $path);
            }
            return $path;
        } else {
            return parent::getConfigGeneratorClassPath($class,
                $directoryPath);
        }
    }


    /**
     * Get stub template for generated file.
     *
     * @return string
     */
    public function getStub()
    {
        $path = config('repository.generator.stubsOverridePath', __DIR__);

        if (!file_exists($path.'/Stubs/'.$this->stub.'.stub')) {
            $path = __DIR__;
        }

        return (new Stub($path.'/Stubs/'.$this->stub.'.stub', $this->getReplacements()))->render();
    }
}
